# Install the relevant data files to a subdir of the datadir
foamsimdatadir = $(datadir)/foam/simdata

# Crop wavefront file (asymmetric is better for testing)
wavefront-crop*: wavefront.fits
	convert wavefront.fits -depth 8 -crop 1024x768+0+128 wavefront-crop.fits
	convert wavefront-crop.fits wavefront-crop.png

# Convert wavefront file to png
wavefront.png: wavefront.fits
	convert wavefront.fits wavefront.png

# PGMs are the source data. Convert to fits if they do not already exist
simstatic*.fits:
	@echo Converting datafiles...
	@for f in *pgm; \
		do \
		if [[ ! -f $$f.fits ]]; then echo "$$f -> $$f.fits..."; convert $$f $$f.fits; fi; \
	done;
	@echo "done."

# Clean files generated by the above targets
clean-local:
	@echo Cleaning processed datafiles
	@rm -f wavefront-crop*
	@rm -f wavefront.png
	@rm -f simstatic*.fits

# Include these files in th distribution (the other files depend on them)
dist_foamsimdata_DATA = simstatic*.pgm wavefront.fits simulwfc.csv

# These files are generated from the above files and do not need to be included in the distribution
foamsimdata_DATA = simstatic*.fits wavefront.png wavefront-crop* 

foamalpaodatadir = $(datadir)/foam/alpao
dist_foamalpaodata_DATA = alpao/alpaoHSDM97-15-031 alpao/alpaoHSDM97-15-031.acfg

